﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using LibHuman;

namespace Human
{
	/// <summary>
	/// Summary description for frmHopdong_khenthuong.
	/// </summary>
	public class frmHopdong_khenthuong : System.Windows.Forms.Form
	{
		private AccessData mDB=new AccessData();
        Language lan = new Language();
		private DataSet ds=new DataSet();
		private string v_manv="",m_user="";
        bool b_ktkt = false;
		private System.Windows.Forms.DataGrid dgrTTKhenThuong;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.Label label7;
		private System.Windows.Forms.Label label8;
		private System.Windows.Forms.Label label9;
		private System.Windows.Forms.Label label10;
		private System.Windows.Forms.Panel panel1;
		private PinkieControls.ButtonXP btnSua;
		private PinkieControls.ButtonXP btnBoqua;
		private PinkieControls.ButtonXP btnHuy;
		private PinkieControls.ButtonXP btnThem;
		private PinkieControls.ButtonXP btnLuu;
		private PinkieControls.ButtonXP btnKetthuc;
		private System.Windows.Forms.TextBox txtHT_KT;
        private System.Windows.Forms.TextBox txtND_KT;
		private System.Windows.Forms.TextBox txtGC_KT;
		private System.Windows.Forms.TextBox txtVBS_KT;
        private MaskedTextBox txtN_KT;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmHopdong_khenthuong(string v_manv,bool m_ktkl,string lbl)
		{
			InitializeComponent();
            lan.Read_Language_to_Xml(this.Name.ToString(), this);
            lan.Changelanguage_to_English(this.Name.ToString(), this);
            this.v_manv = v_manv;
            this.Text = lbl;
            m_user = mDB.user;
            b_ktkt = m_ktkl; 		
        }
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmHopdong_khenthuong));
            this.dgrTTKhenThuong = new System.Windows.Forms.DataGrid();
            this.label6 = new System.Windows.Forms.Label();
            this.txtHT_KT = new System.Windows.Forms.TextBox();
            this.label7 = new System.Windows.Forms.Label();
            this.txtND_KT = new System.Windows.Forms.TextBox();
            this.txtGC_KT = new System.Windows.Forms.TextBox();
            this.label8 = new System.Windows.Forms.Label();
            this.label9 = new System.Windows.Forms.Label();
            this.label10 = new System.Windows.Forms.Label();
            this.txtVBS_KT = new System.Windows.Forms.TextBox();
            this.panel1 = new System.Windows.Forms.Panel();
            this.btnBoqua = new PinkieControls.ButtonXP();
            this.btnHuy = new PinkieControls.ButtonXP();
            this.btnThem = new PinkieControls.ButtonXP();
            this.btnLuu = new PinkieControls.ButtonXP();
            this.btnKetthuc = new PinkieControls.ButtonXP();
            this.btnSua = new PinkieControls.ButtonXP();
            this.txtN_KT = new System.Windows.Forms.MaskedTextBox();
            ((System.ComponentModel.ISupportInitialize)(this.dgrTTKhenThuong)).BeginInit();
            this.panel1.SuspendLayout();
            this.SuspendLayout();
            // 
            // dgrTTKhenThuong
            // 
            this.dgrTTKhenThuong.AlternatingBackColor = System.Drawing.Color.Lavender;
            this.dgrTTKhenThuong.BackColor = System.Drawing.Color.WhiteSmoke;
            this.dgrTTKhenThuong.BackgroundColor = System.Drawing.SystemColors.Control;
            this.dgrTTKhenThuong.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.dgrTTKhenThuong.CaptionBackColor = System.Drawing.Color.LightSteelBlue;
            this.dgrTTKhenThuong.CaptionForeColor = System.Drawing.Color.MidnightBlue;
            this.dgrTTKhenThuong.CaptionText = "Thông tin về khen thưởng";
            this.dgrTTKhenThuong.CaptionVisible = false;
            this.dgrTTKhenThuong.DataMember = "";
            this.dgrTTKhenThuong.FlatMode = true;
            this.dgrTTKhenThuong.Font = new System.Drawing.Font("Tahoma", 8F);
            this.dgrTTKhenThuong.ForeColor = System.Drawing.Color.MidnightBlue;
            this.dgrTTKhenThuong.GridLineColor = System.Drawing.Color.Gainsboro;
            this.dgrTTKhenThuong.GridLineStyle = System.Windows.Forms.DataGridLineStyle.None;
            this.dgrTTKhenThuong.HeaderBackColor = System.Drawing.Color.MidnightBlue;
            this.dgrTTKhenThuong.HeaderFont = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold);
            this.dgrTTKhenThuong.HeaderForeColor = System.Drawing.Color.WhiteSmoke;
            this.dgrTTKhenThuong.LinkColor = System.Drawing.Color.Teal;
            this.dgrTTKhenThuong.Location = new System.Drawing.Point(8, 8);
            this.dgrTTKhenThuong.Name = "dgrTTKhenThuong";
            this.dgrTTKhenThuong.ParentRowsBackColor = System.Drawing.Color.Gainsboro;
            this.dgrTTKhenThuong.ParentRowsForeColor = System.Drawing.Color.MidnightBlue;
            this.dgrTTKhenThuong.RowHeaderWidth = 10;
            this.dgrTTKhenThuong.SelectionBackColor = System.Drawing.Color.CadetBlue;
            this.dgrTTKhenThuong.SelectionForeColor = System.Drawing.Color.WhiteSmoke;
            this.dgrTTKhenThuong.Size = new System.Drawing.Size(592, 264);
            this.dgrTTKhenThuong.TabIndex = 167;
            this.dgrTTKhenThuong.CurrentCellChanged += new System.EventHandler(this.dgrTTKhenThuong_CurrentCellChanged);
            // 
            // label6
            // 
            this.label6.AutoSize = true;
            this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label6.ForeColor = System.Drawing.Color.DarkBlue;
            this.label6.Location = new System.Drawing.Point(40, 284);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(32, 13);
            this.label6.TabIndex = 180;
            this.label6.Text = "Ngày";
            this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // txtHT_KT
            // 
            this.txtHT_KT.BackColor = System.Drawing.Color.White;
            this.txtHT_KT.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtHT_KT.Location = new System.Drawing.Point(464, 280);
            this.txtHT_KT.MaxLength = 30;
            this.txtHT_KT.Name = "txtHT_KT";
            this.txtHT_KT.Size = new System.Drawing.Size(131, 21);
            this.txtHT_KT.TabIndex = 12;
            this.txtHT_KT.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtHT_KT_KeyDown);
            // 
            // label7
            // 
            this.label7.AutoSize = true;
            this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label7.ForeColor = System.Drawing.Color.DarkBlue;
            this.label7.Location = new System.Drawing.Point(163, 283);
            this.label7.Name = "label7";
            this.label7.Size = new System.Drawing.Size(50, 13);
            this.label7.TabIndex = 181;
            this.label7.Text = "Nội dung";
            this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // txtND_KT
            // 
            this.txtND_KT.BackColor = System.Drawing.Color.White;
            this.txtND_KT.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtND_KT.Location = new System.Drawing.Point(224, 280);
            this.txtND_KT.MaxLength = 60;
            this.txtND_KT.Name = "txtND_KT";
            this.txtND_KT.Size = new System.Drawing.Size(176, 20);
            this.txtND_KT.TabIndex = 11;
            this.txtND_KT.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtND_KT_KeyDown);
            // 
            // txtGC_KT
            // 
            this.txtGC_KT.BackColor = System.Drawing.Color.White;
            this.txtGC_KT.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtGC_KT.Location = new System.Drawing.Point(224, 302);
            this.txtGC_KT.MaxLength = 60;
            this.txtGC_KT.Name = "txtGC_KT";
            this.txtGC_KT.Size = new System.Drawing.Size(371, 20);
            this.txtGC_KT.TabIndex = 14;
            this.txtGC_KT.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtGC_KT_KeyDown);
            // 
            // label8
            // 
            this.label8.AutoSize = true;
            this.label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label8.ForeColor = System.Drawing.Color.DarkBlue;
            this.label8.Location = new System.Drawing.Point(8, 305);
            this.label8.Name = "label8";
            this.label8.Size = new System.Drawing.Size(61, 13);
            this.label8.TabIndex = 183;
            this.label8.Text = "Văn bản số";
            this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label9
            // 
            this.label9.AutoSize = true;
            this.label9.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label9.ForeColor = System.Drawing.Color.DarkBlue;
            this.label9.Location = new System.Drawing.Point(405, 283);
            this.label9.Name = "label9";
            this.label9.Size = new System.Drawing.Size(53, 13);
            this.label9.TabIndex = 182;
            this.label9.Text = "Hình thức";
            this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label10
            // 
            this.label10.AutoSize = true;
            this.label10.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label10.ForeColor = System.Drawing.Color.DarkBlue;
            this.label10.Location = new System.Drawing.Point(169, 307);
            this.label10.Name = "label10";
            this.label10.Size = new System.Drawing.Size(44, 13);
            this.label10.TabIndex = 184;
            this.label10.Text = "Ghi chú";
            this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // txtVBS_KT
            // 
            this.txtVBS_KT.BackColor = System.Drawing.Color.White;
            this.txtVBS_KT.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtVBS_KT.Location = new System.Drawing.Point(80, 302);
            this.txtVBS_KT.MaxLength = 30;
            this.txtVBS_KT.Name = "txtVBS_KT";
            this.txtVBS_KT.Size = new System.Drawing.Size(80, 20);
            this.txtVBS_KT.TabIndex = 13;
            this.txtVBS_KT.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtVBS_KT_KeyDown);
            // 
            // panel1
            // 
            this.panel1.Controls.Add(this.btnBoqua);
            this.panel1.Controls.Add(this.btnHuy);
            this.panel1.Controls.Add(this.btnThem);
            this.panel1.Controls.Add(this.btnLuu);
            this.panel1.Controls.Add(this.btnKetthuc);
            this.panel1.Location = new System.Drawing.Point(120, 344);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(338, 38);
            this.panel1.TabIndex = 190;
            // 
            // btnBoqua
            // 
            this.btnBoqua.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
            this.btnBoqua.DefaultScheme = true;
            this.btnBoqua.DialogResult = System.Windows.Forms.DialogResult.None;
            this.btnBoqua.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btnBoqua.ForeColor = System.Drawing.Color.DarkBlue;
            this.btnBoqua.Hint = "";
            this.btnBoqua.Image = global::Human.Properties.Resources.t_boqua1;
            this.btnBoqua.Location = new System.Drawing.Point(127, 4);
            this.btnBoqua.Name = "btnBoqua";
            this.btnBoqua.Scheme = PinkieControls.ButtonXP.Schemes.Blue;
            this.btnBoqua.Size = new System.Drawing.Size(74, 28);
            this.btnBoqua.TabIndex = 4;
            this.btnBoqua.Text = "&Bỏ qua";
            this.btnBoqua.TextColor = System.Drawing.Color.DarkBlue;
            this.btnBoqua.Click += new System.EventHandler(this.btnBoqua_Click);
            // 
            // btnHuy
            // 
            this.btnHuy.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
            this.btnHuy.DefaultScheme = true;
            this.btnHuy.DialogResult = System.Windows.Forms.DialogResult.None;
            this.btnHuy.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btnHuy.ForeColor = System.Drawing.Color.DarkBlue;
            this.btnHuy.Hint = "";
            this.btnHuy.Image = ((System.Drawing.Image)(resources.GetObject("btnHuy.Image")));
            this.btnHuy.Location = new System.Drawing.Point(200, 4);
            this.btnHuy.Name = "btnHuy";
            this.btnHuy.Scheme = PinkieControls.ButtonXP.Schemes.Blue;
            this.btnHuy.Size = new System.Drawing.Size(61, 28);
            this.btnHuy.TabIndex = 5;
            this.btnHuy.Text = "&Xoá ";
            this.btnHuy.TextColor = System.Drawing.Color.DarkBlue;
            this.btnHuy.Click += new System.EventHandler(this.btnHuy_Click);
            // 
            // btnThem
            // 
            this.btnThem.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
            this.btnThem.DefaultScheme = true;
            this.btnThem.DialogResult = System.Windows.Forms.DialogResult.None;
            this.btnThem.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btnThem.ForeColor = System.Drawing.Color.DarkBlue;
            this.btnThem.Hint = "";
            this.btnThem.Image = ((System.Drawing.Image)(resources.GetObject("btnThem.Image")));
            this.btnThem.Location = new System.Drawing.Point(2, 4);
            this.btnThem.Name = "btnThem";
            this.btnThem.Scheme = PinkieControls.ButtonXP.Schemes.Blue;
            this.btnThem.Size = new System.Drawing.Size(63, 28);
            this.btnThem.TabIndex = 1;
            this.btnThem.Text = "&Mới";
            this.btnThem.TextColor = System.Drawing.Color.DarkBlue;
            this.btnThem.Click += new System.EventHandler(this.btnThem_Click);
            // 
            // btnLuu
            // 
            this.btnLuu.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
            this.btnLuu.DefaultScheme = true;
            this.btnLuu.DialogResult = System.Windows.Forms.DialogResult.None;
            this.btnLuu.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btnLuu.ForeColor = System.Drawing.Color.DarkBlue;
            this.btnLuu.Hint = "";
            this.btnLuu.Image = ((System.Drawing.Image)(resources.GetObject("btnLuu.Image")));
            this.btnLuu.Location = new System.Drawing.Point(64, 4);
            this.btnLuu.Name = "btnLuu";
            this.btnLuu.Scheme = PinkieControls.ButtonXP.Schemes.Blue;
            this.btnLuu.Size = new System.Drawing.Size(63, 28);
            this.btnLuu.TabIndex = 3;
            this.btnLuu.Text = "&Lưu";
            this.btnLuu.TextColor = System.Drawing.Color.DarkBlue;
            this.btnLuu.Click += new System.EventHandler(this.btnLuu_Click);
            this.btnLuu.KeyDown += new System.Windows.Forms.KeyEventHandler(this.btnLuu_KeyDown);
            // 
            // btnKetthuc
            // 
            this.btnKetthuc.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
            this.btnKetthuc.DefaultScheme = true;
            this.btnKetthuc.DialogResult = System.Windows.Forms.DialogResult.None;
            this.btnKetthuc.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btnKetthuc.ForeColor = System.Drawing.Color.DarkBlue;
            this.btnKetthuc.Hint = "";
            this.btnKetthuc.Image = ((System.Drawing.Image)(resources.GetObject("btnKetthuc.Image")));
            this.btnKetthuc.Location = new System.Drawing.Point(261, 4);
            this.btnKetthuc.Name = "btnKetthuc";
            this.btnKetthuc.Scheme = PinkieControls.ButtonXP.Schemes.Blue;
            this.btnKetthuc.Size = new System.Drawing.Size(71, 28);
            this.btnKetthuc.TabIndex = 6;
            this.btnKetthuc.Text = "&Thoát";
            this.btnKetthuc.TextColor = System.Drawing.Color.DarkBlue;
            this.btnKetthuc.Click += new System.EventHandler(this.btnKetthuc_Click);
            // 
            // btnSua
            // 
            this.btnSua.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
            this.btnSua.DefaultScheme = true;
            this.btnSua.DialogResult = System.Windows.Forms.DialogResult.None;
            this.btnSua.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btnSua.ForeColor = System.Drawing.Color.DarkBlue;
            this.btnSua.Hint = "";
            this.btnSua.Location = new System.Drawing.Point(537, 344);
            this.btnSua.Name = "btnSua";
            this.btnSua.Scheme = PinkieControls.ButtonXP.Schemes.Blue;
            this.btnSua.Size = new System.Drawing.Size(63, 28);
            this.btnSua.TabIndex = 2;
            this.btnSua.Text = "&Sửa";
            this.btnSua.TextColor = System.Drawing.Color.DarkBlue;
            this.btnSua.Visible = false;
            // 
            // txtN_KT
            // 
            this.txtN_KT.BackColor = System.Drawing.SystemColors.Control;
            this.txtN_KT.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtN_KT.ForeColor = System.Drawing.Color.Navy;
            this.txtN_KT.Location = new System.Drawing.Point(80, 280);
            this.txtN_KT.Mask = "00/00/0000";
            this.txtN_KT.Name = "txtN_KT";
            this.txtN_KT.Size = new System.Drawing.Size(80, 21);
            this.txtN_KT.TabIndex = 10;
            this.txtN_KT.ValidatingType = typeof(System.DateTime);
            this.txtN_KT.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtN_KT_KeyDown);
            this.txtN_KT.Validated += new System.EventHandler(this.txtN_KT_Validated);
            // 
            // frmHopdong_khenthuong
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(608, 389);
            this.Controls.Add(this.txtN_KT);
            this.Controls.Add(this.panel1);
            this.Controls.Add(this.label6);
            this.Controls.Add(this.label7);
            this.Controls.Add(this.label8);
            this.Controls.Add(this.label9);
            this.Controls.Add(this.label10);
            this.Controls.Add(this.btnSua);
            this.Controls.Add(this.txtHT_KT);
            this.Controls.Add(this.txtND_KT);
            this.Controls.Add(this.txtGC_KT);
            this.Controls.Add(this.txtVBS_KT);
            this.Controls.Add(this.dgrTTKhenThuong);
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "frmHopdong_khenthuong";
            this.ShowInTaskbar = false;
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Khen thưởng - Kỷ luật";
            this.Load += new System.EventHandler(this.frmHopdong_khenthuong_Load);
            ((System.ComponentModel.ISupportInitialize)(this.dgrTTKhenThuong)).EndInit();
            this.panel1.ResumeLayout(false);
            this.ResumeLayout(false);
            this.PerformLayout();

		}
		#endregion

		private void frmHopdong_khenthuong_Load(object sender, System.EventArgs e)
		{
            if (b_ktkt)
                kyluat();
            else
                khenthuong();
			Ena_control(true);
			refresh_Text();
			Ena_textbox(false);
			btnThem.Focus();
		}
		private void khenthuong()
		{
            string sql = "";
            try
			{
				sql="SELECT manv,to_char(ngay,'dd/mm/yyyy') as m_ngay, noidung, hinhthuc, vbso, ghichu";
                sql += " FROM " + m_user + ".ktkl WHERE ktkl="+b_ktkt+" and (((manv)='" + v_manv + "'))";
                DataSet ads=mDB.get_data(sql);
				dgrTTKhenThuong.DataSource=null;
				dgrTTKhenThuong.TableStyles.Clear();
				DataGridTableStyle ts = new DataGridTableStyle();
				ts.MappingName = ads.Tables[0].TableName;
					
				ts.AlternatingBackColor = Color.Beige;
				ts.BackColor = Color.GhostWhite;
				ts.ForeColor = Color.MidnightBlue;
				ts.GridLineColor = Color.RoyalBlue;
				ts.HeaderBackColor = Color.MidnightBlue;
				ts.HeaderForeColor = Color.Lavender;
				ts.SelectionBackColor = Color.Teal;
				ts.SelectionForeColor = Color.PaleGreen;
				
				DataGridTextBoxColumn TextCol1=new DataGridTextBoxColumn();
				TextCol1.MappingName = "m_ngay";
				TextCol1.HeaderText = lan.Change_language_MessageText("Ngày");
				TextCol1.Width = 70;
				TextCol1.Alignment=HorizontalAlignment.Left;
				ts.GridColumnStyles.Add(TextCol1);
				dgrTTKhenThuong.TableStyles.Add(ts);
			
				DataGridTextBoxColumn TextCol2=new DataGridTextBoxColumn();
				TextCol2.MappingName = "noidung";
				TextCol2.HeaderText = lan.Change_language_MessageText("Nội dung khen thưởng");
				TextCol2.Width = 200;
				TextCol2.Alignment=HorizontalAlignment.Left;
				ts.GridColumnStyles.Add(TextCol2);
				dgrTTKhenThuong.TableStyles.Add(ts);
			
				DataGridTextBoxColumn TextCol3=new DataGridTextBoxColumn();
				TextCol3.MappingName = "hinhthuc";
				TextCol3.HeaderText = lan.Change_language_MessageText("Hình thức");
				TextCol3.Width = 100;
				TextCol3.Alignment=HorizontalAlignment.Left;
				ts.GridColumnStyles.Add(TextCol3);
				dgrTTKhenThuong.TableStyles.Add(ts);
			
				DataGridTextBoxColumn TextCol4=new DataGridTextBoxColumn();
				TextCol4.MappingName = "vbso";
				TextCol4.HeaderText = lan.Change_language_MessageText("Văn bản số");
				TextCol4.Width = 70;
				TextCol4.Alignment=HorizontalAlignment.Left;
				ts.GridColumnStyles.Add(TextCol4);
				dgrTTKhenThuong.TableStyles.Add(ts);
			
				DataGridTextBoxColumn TextCol5=new DataGridTextBoxColumn();
				TextCol5.MappingName = "ghichu";
				TextCol5.HeaderText = lan.Change_language_MessageText("Ghi Chú");
				TextCol5.Width = 150;
				TextCol5.Alignment=HorizontalAlignment.Left;
				ts.GridColumnStyles.Add(TextCol5);
				dgrTTKhenThuong.TableStyles.Add(ts);
				ts.DataGrid.DataSource=ads.Tables[0]; 		
                //CurrencyManager cm = (CurrencyManager) 
                CurrencyManager cm = (CurrencyManager)BindingContext[dgrTTKhenThuong.DataSource, dgrTTKhenThuong.DataMember];
                DataView dv = (DataView)cm.List;
                dv.AllowNew = false;
			}
			catch{}
		}
        private void kyluat()
        {
            string sql = "";
            try
            {
                //DataSet ads = mDB.f_hopdongKL(v_manv);
                sql = "SELECT manv,to_char(ngay,'dd/mm/yyyy') as mkl_ngay, noidung, hinhthuc, vbso, ghichu";
                sql += " FROM " + m_user + ".ktkl WHERE ktkl=" + b_ktkt + " and (((manv)='" + v_manv + "'))";
                DataSet ads = mDB.get_data(sql);
                dgrTTKhenThuong.DataSource = null;
                dgrTTKhenThuong.TableStyles.Clear();
                DataGridTableStyle ts = new DataGridTableStyle();
                ts.MappingName = ads.Tables[0].TableName;

                ts.AlternatingBackColor = Color.Beige;
                ts.BackColor = Color.GhostWhite;
                ts.ForeColor = Color.MidnightBlue;
                ts.GridLineColor = Color.RoyalBlue;
                ts.HeaderBackColor = Color.MidnightBlue;
                ts.HeaderForeColor = Color.Lavender;
                ts.SelectionBackColor = Color.Teal;
                ts.SelectionForeColor = Color.PaleGreen;

                DataGridTextBoxColumn TextCol1 = new DataGridTextBoxColumn();
                TextCol1.MappingName = "mkl_ngay";
                TextCol1.HeaderText = lan.Change_language_MessageText("Ngày");
                TextCol1.Width = 70;
                TextCol1.Alignment = HorizontalAlignment.Left;
                ts.GridColumnStyles.Add(TextCol1);
                dgrTTKhenThuong.TableStyles.Add(ts);

                DataGridTextBoxColumn TextCol2 = new DataGridTextBoxColumn();
                TextCol2.MappingName = "noidung";
                TextCol2.HeaderText = lan.Change_language_MessageText("Nội dung kỹ luật");
                TextCol2.Width = 200;
                TextCol2.Alignment = HorizontalAlignment.Left;
                ts.GridColumnStyles.Add(TextCol2);
                dgrTTKhenThuong.TableStyles.Add(ts);

                DataGridTextBoxColumn TextCol3 = new DataGridTextBoxColumn();
                TextCol3.MappingName = "hinhthuc";
                TextCol3.HeaderText = lan.Change_language_MessageText("Hình thức");
                TextCol3.Width = 100;
                TextCol3.Alignment = HorizontalAlignment.Left;
                ts.GridColumnStyles.Add(TextCol3);
                dgrTTKhenThuong.TableStyles.Add(ts);

                DataGridTextBoxColumn TextCol4 = new DataGridTextBoxColumn();
                TextCol4.MappingName = "vbso";
                TextCol4.HeaderText = lan.Change_language_MessageText("Văn bản số");
                TextCol4.Width = 70;
                TextCol4.Alignment = HorizontalAlignment.Left;
                ts.GridColumnStyles.Add(TextCol4);
                dgrTTKhenThuong.TableStyles.Add(ts);

                DataGridTextBoxColumn TextCol5 = new DataGridTextBoxColumn();
                TextCol5.MappingName = "ghichu";
                TextCol5.HeaderText = lan.Change_language_MessageText("Ghi Chú");
                TextCol5.Width = 150;
                TextCol5.Alignment = HorizontalAlignment.Left;
                ts.GridColumnStyles.Add(TextCol5);
                dgrTTKhenThuong.TableStyles.Add(ts);

                ts.DataGrid.DataSource = ads.Tables[0];
                CurrencyManager cm = (CurrencyManager)BindingContext[dgrTTKhenThuong.DataSource, dgrTTKhenThuong.DataMember];
                DataView dv = (DataView)cm.List;
                dv.AllowNew = false;
            }
            catch { }
        }

		private void btnThem_Click(object sender, System.EventArgs e)
		{
			Ena_control(false);
			Ena_textbox(true);
			clear_Text();
			txtN_KT.Focus();
		}
		private void Ena_control(bool ena)
		{
			btnThem.Enabled=ena;
			btnSua.Enabled=ena;
			btnLuu.Enabled=!ena;
			btnBoqua.Enabled=!ena;
			btnHuy.Enabled=ena;
			btnKetthuc.Enabled=ena;
		}
		private void Ena_textbox(bool ena)
		{			
			txtN_KT.Enabled=ena;
			txtND_KT.Enabled=ena;
			txtHT_KT.Enabled=ena;
			txtVBS_KT.Enabled=ena;
			txtGC_KT.Enabled=ena;
		}
		private void clear_Text()
		{			
			txtN_KT.Clear();
			txtND_KT.Clear();
			txtHT_KT.Clear();
			txtVBS_KT.Clear();
			txtGC_KT.Clear();
		}
		private void btnBoqua_Click(object sender, System.EventArgs e)
		{
			Ena_control(true);
			refresh_Text();
			Ena_textbox(false);
			btnKetthuc.Focus();
		}
		private void refresh_Text()
		{
			try
			{
				int i=dgrTTKhenThuong.CurrentRowIndex;
				if(i>=0)
				{
					txtN_KT.Text=dgrTTKhenThuong[i,0].ToString();
					txtND_KT.Text=dgrTTKhenThuong[i,1].ToString();
					txtHT_KT.Text=dgrTTKhenThuong[i,2].ToString();
					txtVBS_KT.Text=dgrTTKhenThuong[i,3].ToString();
					txtGC_KT.Text=dgrTTKhenThuong[i,4].ToString();
				}
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.ToString());
			}
		}
		private void btnKetthuc_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void btnLuu_Click(object sender, System.EventArgs e)
		{
			if(!kiemtraKT()) return;
			string  ngay_,nd_kt,hinh_thuc,vb_so,ghi_chu;
			try
			{
				ngay_=txtN_KT.Text;
				nd_kt=txtND_KT.Text;
				hinh_thuc=txtHT_KT.Text;
				vb_so=txtVBS_KT.Text;
				ghi_chu=txtGC_KT.Text;
				mDB.Upd_ktkl(v_manv,ngay_,nd_kt,hinh_thuc,vb_so,ghi_chu,b_ktkt);
                if (b_ktkt)
                    kyluat();
                else
                    khenthuong();
				Ena_control(true);				
				Ena_textbox(false);
				btnThem.Focus();
			}
			catch{}
		}
		private bool kiemtraKT()
		{
			if(txtN_KT.Text=="" || txtN_KT.Text=="__/__/____")
			{
				MessageBox.Show(lan.Change_language_MessageText("Yêu cầu chọn ngày được khen thưởng"),AccessData.Msg);
				txtN_KT.Focus();
				return false;
			}
			if(txtND_KT.Text=="")
			{
				MessageBox.Show(lan.Change_language_MessageText("Yêu cầu nhập nội dung khen thưởng"),AccessData.Msg);
				txtND_KT.Focus();
				return false;
			}
			if(txtHT_KT.Text=="")
			{
				MessageBox.Show(lan.Change_language_MessageText("Yêu cầu nhập hình thức khen thưởng"),AccessData.Msg);
				txtHT_KT.Focus();
				return false;
			}
			if(txtVBS_KT.Text=="")
			{
				MessageBox.Show(lan.Change_language_MessageText("Yêu cầu nhập số văn bản khen thưởng"),AccessData.Msg);
				txtVBS_KT.Focus();
				return false;
			}
			return true;
		}

		private void btnHuy_Click(object sender, System.EventArgs e)
		{
			string ngay_,nd_kt,hinh_thuc,vb_so,ghi_chu,sql="";  
			try
			{
				int i=dgrTTKhenThuong.CurrentCell.RowNumber;
				if(i<0)  
					i=dgrTTKhenThuong.CurrentCell.RowNumber;
				if(i==dgrTTKhenThuong.CurrentCell.RowNumber) 
				{
					DialogResult dr = MessageBox.Show(lan.Change_language_MessageText("Đồng ý hủy thông tin này ?"),AccessData.Msg,MessageBoxButtons.YesNo);								
					if(dr == DialogResult.Yes) 		
					{
						ngay_=dgrTTKhenThuong[i,0].ToString();
						nd_kt=dgrTTKhenThuong[i,1].ToString();
						hinh_thuc=dgrTTKhenThuong[i,2].ToString();
						vb_so=dgrTTKhenThuong[i,3].ToString();
						ghi_chu=dgrTTKhenThuong[i,4].ToString();
                        sql = "DELETE   FROM " + m_user + ".ktkl ";
                        sql += " WHERE manv='" + v_manv + "'";
                        sql += " AND ktkl=false";
                        sql += " AND to_char(ngay,'dd/mm/yyyy')='" + ngay_ + "'";
                        mDB.Execute_data(sql); //f_Delluoihdkt(v_manv,ngay_,nd_kt,hinh_thuc,vb_so,ghi_chu);
						i=dgrTTKhenThuong.CurrentRowIndex;
                        if (b_ktkt)
                            kyluat();
                        else
                            khenthuong();
						refresh_Text();		
					}
				}  
			}
			catch{}
		}

		private void txtN_KT_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyCode==Keys.Enter)
				SendKeys.Send("{Tab}");
		}

		private void txtND_KT_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyCode==Keys.Enter)
				SendKeys.Send("{Tab}");
		}

		private void txtHT_KT_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyCode==Keys.Enter)
				SendKeys.Send("{Tab}");
		}

		private void txtVBS_KT_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyCode==Keys.Enter)
				SendKeys.Send("{Tab}");
		}

		private void txtGC_KT_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyCode==Keys.Enter)
				btnLuu.Focus();
		}

		private void btnLuu_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyCode==Keys.Enter)
				btnKetthuc.Focus();
		}

		private void dgrTTKhenThuong_CurrentCellChanged(object sender, System.EventArgs e)
		{
			try
			{
				refresh_Text();
			}
			catch{}
		}

        private void txtN_KT_Validated(object sender, EventArgs e)
        {
            txtN_KT.Text = txtN_KT.Text.Trim();
            if (txtN_KT.Text == "  /  /")
            {
                return;
            }
            if (!mDB.kiemtrangayhople(txtN_KT.Text.Trim()))
            {
                txtN_KT.Focus();
                return;
            }
        }
	}
}
